/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package syncmellariusnote.helpers;

import com.dao.access.GenericDAO;
import com.dao.access.GenericDAOImp;
import com.model.access.*;
import java.util.Date;

/**
 *
 * @author Vitor
 */
public class RepoHelper  {

    GenericDAO genericDAO;
    AccessObjectRepo accessObjectRepo = new AccessObjectRepo();

    public RepoHelper() {
        genericDAO = new GenericDAOImp() {
        };
    }

    public AccessObjectRepo populateRepoAccess() {
        setAccessObjects();
        return accessObjectRepo;
    }

    public void populateRepoSqlite() {

    }

    private void setAccessObjects() {

        accessObjectRepo.setAgenda(genericDAO.findAll(AgendaApis.class));
        accessObjectRepo.setApiario(genericDAO.findAll(Apiario.class));
        accessObjectRepo.setApiarioFlora(genericDAO.findAll(ApiarioFlora.class));
        accessObjectRepo.setApicultor(genericDAO.findAll(Apicultor.class));
        accessObjectRepo.setAssociacoes(genericDAO.findAll(Associacoes.class));
        accessObjectRepo.setClassificassao(genericDAO.findAll(Classificasao.class));
        accessObjectRepo.setCodIne(genericDAO.findAll(CodIne.class));
        accessObjectRepo.setCriaRainhas(genericDAO.findAll(CriaRainhas.class));
        accessObjectRepo.setEnxame(genericDAO.findAll(Enxame.class));
        accessObjectRepo.setEstrados(genericDAO.findAll(Estrados.class));
        //accessObjectRepo.setFlora(genericDAO.findAll(Flora.class));
        accessObjectRepo.setFormaAlimentacao(genericDAO.findAll(FormaAlimentacao.class));
        accessObjectRepo.setGrauDefesa(genericDAO.findAll(GrauDefesa.class));
        accessObjectRepo.setGrupoActividade(genericDAO.findAll(Gruposactiv.class));
        accessObjectRepo.setGrupos(genericDAO.findAll(Grupos.class));
        accessObjectRepo.setHistorico(genericDAO.findAll(Historico.class));
        accessObjectRepo.setManutencoes(genericDAO.findAll(Manutencoes.class));
        accessObjectRepo.setManutencoesColm(genericDAO.findAll(Manutencoescolm.class));
        accessObjectRepo.setMedicamentos(genericDAO.findAll(Medicamentos.class));
        accessObjectRepo.setMelgueiras(genericDAO.findAll(Melgueiras.class));
        accessObjectRepo.setMeses(genericDAO.findAll(Meses.class));
        accessObjectRepo.setMetodosIntro(genericDAO.findAll(MetodosIntro.class));
        accessObjectRepo.setMetosCriacao(genericDAO.findAll(MetodosCriacao.class));
        accessObjectRepo.setNacionalidades(genericDAO.findAll(Nacionalidades.class));
        accessObjectRepo.setNiveisReservas(genericDAO.findAll(NiveisReservas.class));
        accessObjectRepo.setPragas(genericDAO.findAll(Pragas.class));
        accessObjectRepo.setQualidadeMel(genericDAO.findAll(QualidMel.class));
        accessObjectRepo.setRacas(genericDAO.findAll(Racas.class));
        accessObjectRepo.setRainhas(genericDAO.findAll(Rainhas.class));
        accessObjectRepo.setRegAlimentacoes(genericDAO.findAll(RegAlimentacoes.class));
        accessObjectRepo.setRegEnxames(genericDAO.findAll(RegEnxames.class));
        accessObjectRepo.setRegPragas(genericDAO.findAll(RegPragas.class));
        accessObjectRepo.setTipoAlimentacao(genericDAO.findAll(TipoAlimentacao.class));
        accessObjectRepo.setTipoColmeia(genericDAO.findAll(TipoColmeia.class));
        accessObjectRepo.setTipoExistenciaFlores(genericDAO.findAll(TiposExitenciaFlores.class));
        accessObjectRepo.setTiposIntervencao(genericDAO.findAll(TiposIntervencao.class));
        accessObjectRepo.setTiposOrigem(genericDAO.findAll(TiposOrigem.class));
        accessObjectRepo.setTrocasCera(genericDAO.findAll(TrocasCera.class));

    }

    public static String verifyDateToString(Date string) {
        String stringAux;
        if (string == null) {
            stringAux = "";
        } else {
            stringAux = string.toString();
        }
        return stringAux;
    }

    public static Date verifyDate(Date string) {
        Date stringAux = string;
        if (stringAux == null) {
            stringAux = new Date();
        }
        return stringAux;
    }

    public static int verifyShortToInt(Short number) {
        int integerAux = 0;

        if (number != null) {

            integerAux = number.intValue();
        }
        return integerAux;
    }

    public static int verifyInt(Integer number) {
        int integerAux = 0;

        if (number != null) {

            integerAux = number;
        }
        return integerAux;
    }

    public static String verifyString(String string) {
        String stringAux;
        if (string == null) {
            stringAux = "";
        } else {
            stringAux = string;
        }
        return stringAux;
    }

    public static int verifyDouble(Double number) {
        int integerAux = 0;

        if (number != null) {

            integerAux = number.intValue();
        }
        return integerAux;
    }
    public static boolean verifyBoolean(Boolean bool) {
        Boolean boolAux = false;

        if (bool != null) {

            boolAux = bool;
        }
        return boolAux;
    }
    public static Object verifyObject(Object bool) {
        Object boolAux = null;

        if (bool != null) {

            boolAux = bool;
        }
        return boolAux;
    }

}
